哈囉,各位邦友們!
今天我們試著用最新的 Angular CLI 來建立一個 Standalone 專案,並快速認識專案結構。
一、建立專案與啟動
使用全域 CLI(建議先更新到最新版):
npm i -g @angular/cli@latest
ng new hero-journey --style=scss --routing=false
? Do you want to enable Server-Side Rendering (SSR) and Static Site Generation
(SSG/Prerendering)? (y/N) y
? Do you want to create a 'zoneless' application without zone.js? (y/N) y
? Which AI tools do you want to configure with Angular best practices?
https://angular.dev/ai/develop-with-ai (Press <space> to select, <a> to toggle
all, <i> to invert selection, and <enter> to proceed)
❯◉ None
◯ Claude [ https://docs.anthropic.com/en/docs/claude-code/memory
]
◯ Cursor [ https://docs.cursor.com/en/context/rules
]
◯ Gemini [ https://ai.google.dev/gemini-api/docs
]
cd hero-journey
ng serve
Would you like to share pseudonymous usage data about this project with the
Angular Team
at Google under Google's Privacy Policy at https://policies.google.com/privacy.
For more
details and how to change this setting, see https://angular.dev/cli/analytics.
(y/N) N
二、專案結構說明
// src/main.ts
// ...existing code...
bootstrapApplication(AppComponent, {
providers: [
// 未來:provideRouter(routes), provideHttpClient(), ...
]
});
// ...existing code...
三、簡單練習(設定路徑別名)
{
"compilerOptions": {
// ...existing options...
"paths": {
"@app/*": ["src/app/*"],
"@assets/*": ["src/assets/*"]
}
}
}
驗收清單:
常見錯誤與排查:
今日小結: